import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

const login = r =>
  require.ensure([], () => r(require("./components/login")), "login");

const home = r => require.ensure([], () => r(require("./views/Home")), "home");

//词条界面
const homeManager = r =>
  require.ensure(
    [],
    () => r(require("./components/homeManager")),
    "homeManager"
  );

//用户管理
const userManager = r =>
  require.ensure(
    [],
    () => r(require("./components/userManager")),
    "userManager"
  );

//项目管理
const projManager = r =>
  require.ensure(
    [],
    () => r(require("./components/projManager")),
    "projManager"
  );

export default new Router({
  mode: "history",
  base: process.env.BASE_URL,
  routes: [
    {
      path: "/",
      component: login,
      name: "login"
      // redirect: "/login"
    },
    { path: "*", component: login }, //找不到的页面应该放404页面
    {
      path: "/login",
      component: login
    },
    {
      path: "/homeManager",
      component: home,
      children: [
        {
          path: "/",
          component: homeManager, //summernoteEditor
          meta: ["项目", "极简汇率-App"]
        },
        {
          path: "/userManager",
          component: userManager,
          meta: ["管理", "用户管理"]
        },
        {
          path: "/projManager",
          component: projManager,
          meta: ["管理", "项目管理"]
        }
      ]
    }
    // {
    //   path: "/about",
    //   name: "about",
    //   // route level code-splitting
    //   // this generates a separate chunk (about.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () =>
    //     import(/* webpackChunkName: "about" */ "./views/About.vue")
    // }
  ]
});
